﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using The_LarX;

namespace LarX_Editor
{
    public partial class NodeInformationHandler : Form
    {
        public NodeInformation Information;
        private VisualScriptEditor Editor;

        List<TextBox> Boxes = new List<TextBox>();
        public NodeInformationHandler(NodeInformation information, VisualScriptEditor editor)
        {
            this.Editor = editor;
            this.Information = information;
            InitializeComponent();
            Start();
        }

        private void Start()
        {
            List<string> descriptions = Information.Descriptions;
            int XStart = 50;
            int YStart = 50;
            int Spacing = 50;
            for (int i = 0; i < descriptions.Count; i++)
            {
                Label label = new Label();
                label.Text = descriptions[i];
                label.Location = new Point(XStart, (Spacing * i) + YStart);
                TextBox box = new TextBox();
                box.Location = new Point(XStart + 50 + label.Width, label.Location.Y);
                Boxes.Add(box);

                this.Controls.Add(label);
                this.Controls.Add(box);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Information.Answers = new List<string>();
            for (int i = 0; i < Boxes.Count; i++)
            {
                Information.Answers.Add(Boxes[i].Text);
            }
            Editor.ReceiveInformation(Information);
            this.Close();
        }
    }
}
